//
//  CustomNavigationBar.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/7/24.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

class CustomNavigationBar: UINavigationBar {
    override func layoutSubviews() {
        super.layoutSubviews()
        if #available(iOS 11, *) {
        self.frame = CGRect(x: 0, y: 0, width: kSCREEN_WIDTH, height: kNavi_HEIGHT)
        for view in self.subviews {
            if String(describing: type(of:view)).contains("Background") {
                view.frame = self.bounds
            }else if String(describing: type(of:view)).contains("ContentView") {
                if isiPhoneX() {
                var frame = view.frame
                frame.size.height = self.bounds.size.height - frame.origin.y
                view.frame = CGRect(x: 0, y: 44, width: kSCREEN_WIDTH, height: kNavi_HEIGHT-44)
                }else {
                    var frame = view.frame
                    frame.size.height = self.bounds.size.height - frame.origin.y
                    view.frame = CGRect(x: 0, y: 20, width: kSCREEN_WIDTH, height: kNavi_HEIGHT-20)
                }
                
            }
         }
      }
        
    }
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
